<template>
  <div>
    <Echart
      id="centreLeft3Chart2"
      ref="centreLeft3ChartRef"
      :options="options"
      height="244px"
      width="472px"
    ></Echart>
  </div>
</template>

<script>
import Echart from '@/common/echart';
export default {
  data() {
    return {
      options: {},
    };
  },
  components: {
    Echart,
  },
  props: {
    cdata: {
      type: Array,
      default: () => {
        return []
      },
    },
  },
  watch: {
    cdata: {
      handler(newData){
        if(newData){
          this.getData(newData)
        }
      },
      immediate: true,
      deep: true,
    },
  },
  methods: {
    getData(v){
      const colors = ["#ddae34", "#e79186", "#306fff", "#30c9c9"];

      this.options = {
        color: colors,
        tooltip: {
          trigger: 'item'
        },
        series: [
          {
            type: 'pie',
            radius: ['50%', '70%'],
            center: ['50%', '50%'],
            data: v,
          }
        ]
      };
    }
  },
};
</script>
